home *** CD-ROM | disk | FTP | other *** search
- function Queue(ExecCount)
- {
- this.ExecCount=ExecCount;
- this.Queue=new Array();
- this.Active=false;
- this.lastUsed=1;
- this.queueStatus=new Array();
- for(i=1;i<=ExecCount;i++)
- this.queueStatus[i]=0;
-
- this.start=startQueue;
- this.stop=stopQueue;
- this.pop=enterCommand;
- this.free=freeQueue;
- this.debug=debug;
- this.debugWin=false;
- }
-
- function startQueue()
- {
- if(this.Queue.length!=0)
- {
- var execindex=0;
- var obj;
- var foundEmpty=-1;
- do
- {
- execindex++;
- if(this.queueStatus[execindex]==0)
- foundEmpty=execindex;
- }
- while(execindex<this.ExecCount && foundEmpty==-1);
- if(foundEmpty!=-1)
- {
- this.queueStatus[foundEmpty]=1;
- var page=this.Queue.shift();
- obj=eval("queue"+foundEmpty);
- obj.location.href=page;
- this.Active=window.setTimeout("queue.start();",10);
- }
- else
- this.Active=window.setTimeout("queue.start();",1000);
- }
- else
- this.Active=window.setTimeout("queue.start();",1000);
- }
-
- function freeQueue(queue)
- {
- var no=(queue.substring(5,queue.length))*1;
- this.queueStatus[no]=0;
- }
-
- function stopQueue()
- {
- if(this.Active!=false)
- window.clearTimeout(this.Active);
- }
-
- function enterCommand(page)
- {
- this.Queue.push(page);
- }
-
- function debug()
- {
- if(!this.debugWin)
- this.debugWin=window.open("", "QueueDebug", "width=500,height=150,dependent=yes,resizable=yes");
- var str='';
- var execindex=0;
- var obj;
- str+="on Queue: "+this.Queue+"<br><br>\n"
- do
- {
- execindex++;
- str+=execindex+": "+this.queueStatus[execindex];
- if(this.queueStatus[execindex]==1)
- {
- obj=eval("queue"+execindex);
- str+=" "+obj.location.href;
- }
- str+="<br>\n";
- }
- while(execindex<this.ExecCount);
- this.debugWin.document.open();
- this.debugWin.document.write(str);
- this.debugWin.document.close();
- this.Active=window.setTimeout("queue.debug();",100);
- }